<template>
	<view class="con">
		<!-- 个人信息模块 (分用户登录与否) -->
		<!-- 用户已登录的个人信息模块 -->
		<view v-if="isLogin" class="userinfo">
			<view class="userinfo-con">
				<view class="userinfo-avatar">
					<image :src="avatarUrl" mode=""></image>
				</view>
				<view class="userinfo-name">
					{{name}}
				</view>
			</view>
		</view>
		<!-- 用户未登录的个人信息模块 -->
		<view class="userinfo-none" v-if="!isLogin">
			<view class="userinfo-none-avatar" @tap="goToUserLogin">
				<image src="@/static/images/user/touxiang.png" @tap="goToUserLogin" />
			</view>
			<view class="userinfo-none-login">
				<button class="unlogin" @tap="goToUserLogin">
					未登录
				</button>
			</view>
		</view>
		<!-- 余额模块 -->
		<view class="money">
			占个位置
		</view>
		<!-- 订单模块 -->
		<view class="list-cont">
			<!-- 订单状态 -->
			<view class="total-order">
				<view class="order-tit">
					<text style="font-weight:bold">
						我的订单
					</text>
					<view class="checkmore" data-sts="0" @tap="toOrderListPage">
						<text>>>查看全部</text>
						<text class="arrowhead" />
					</view>
				</view>
				<view class="procedure">
					<view class="items" data-sts="1" @tap="toOrderListPage">
						<image src="@/static/images/user/toPay.png" />
						<text>待支付</text>
						<text v-if="orderAmount.unPay>0" class="num-badge">
							{{ orderAmount.unPay }}
						</text>
					</view>
					<view class="items" data-sts="2" @tap="toOrderListPage">
						<image src="@/static/images/user/toDelivery.png" />
						<text>待发货</text>
						<text v-if="orderAmount.payed>0" class="num-badge">
							{{ orderAmount.payed }}
						</text>
					</view>
					<view class="items" data-sts="3" @tap="toOrderListPage">
						<image src="@/static/images/user/toTake.png" />
						<text>待收货</text>
						<text v-if="orderAmount.consignment>0" class="num-badge">
							{{ orderAmount.consignment }}
						</text>
					</view>
					<view class="items" data-sts="5" @tap="toOrderListPage">
						<image src="@/static/images/user/toComment.png" />
						<text>已完成</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 任务模块 -->
		<view class="task-cont">
			<view class="task-row">
				<view class="task-item" @tap="cityPartnerApplication">
					<image src="@/static/images/user/application.png" mode=""></image>
					<text>区域申请</text>
				</view>
				<view class="task-item" @tap="butlerApplication">
					<image src="@/static/images/user/application.png" mode=""></image>
					<text>管家申请</text>
				</view>
				<view class="task-item" @tap="shopApplication">
					<image src="@/static/images/user/application.png" mode=""></image>
					<text>商家申请</text>
				</view>
				<view class="task-item" @tap="lawyerApplication">
					<image src="@/static/images/user/application.png" mode=""></image>
					<text>律师申请</text>
				</view>
				<view class="task-item" @tap="assistantApplication">
					<image src="@/static/images/user/application.png" mode=""></image>
					<text>助手申请</text>
				</view>
			</view>
			<view class="task-row">
				<view class="task-item">
					<image src="@/static/images/user/back.png" mode=""></image>
					<text>区域后台</text>
				</view>
				<view class="task-item">
					<image src="@/static/images/user/back.png" mode=""></image>
					<text>管家后台</text>
				</view>
				<view class="task-item">
					<image src="@/static/images/user/back.png" mode=""></image>
					<text>商家后台</text>
				</view>
				<view class="task-item">
					<image src="@/static/images/user/back.png" mode=""></image>
					<text>助手后台</text>
				</view>
			</view>
			<view class="task-row">
				<view class="task-item">
					<image src="@/static/images/user/toLogin.png" mode=""></image>
					<text>账号登录</text>
				</view>
				<view class="task-item">
					<image src="@/static/images/user/share.png" mode=""></image>
					<text>分享</text>
				</view>
				<view class="task-item">
					<image src="@/static/images/user/settings.png" mode=""></image>
					<text>设置</text>
				</view>
				<view class="task-item">
					<image src="" mode=""></image>
					<text></text>
				</view>
			</view>
			
		</view>

	</view>
</template>

<script setup>
	// 个人信息模块
	const isLogin = ref(false)
	const avatarUrl = ref("")
	const name = ref("")

	function goToUserLogin() {
		uni.navigateTo({
			url: "/pages/userLogin/userLogin"
		})
	}

	// 订单模块
	const orderAmount = ref({
		unPay: 1,
		payed: 2,
		consignment: 3

	})
	
	// 任务模块
	
	// 商家申请
	function shopApplication(){
		uni.navigateTo({
			url:"/pages/application/shopapplication"
		})
	}
	// 小助手申请
	function assistantApplication(){
		uni.navigateTo({
			url:"/pages/application/assistantapplication"
		})
	}
	// 管家申请
	function butlerApplication(){
		uni.navigateTo({
			url:"/pages/application/bulterapplication"
		})
	}
	// 律师申请
	function lawyerApplication(){
		uni.navigateTo({
			url:"/pages/application/lawyerapplication"
		})
	}
	// 城市合伙人申请
	function cityPartnerApplication(){
		uni.navigateTo({
			url:"/pages/application/citypartnerapplication"
		})
	}
	onShow(() => {
		uni.$on('ret', (value) => {
			console.log('接收到的值：', value);
			// 进行相应的处理
			isLogin.value = value.isLogin
			avatarUrl.value = value.avatarUrl
			name.value = value.name
		});
	})
	onUnload(()=>{
		// 移除监听事件
		 uni.$off('ret');  
	})
</script>

<style lang="scss" scoped>
	@import "./user.scss";
</style>